//
//  selectBankView.m
//  bankdemo
//
//  Created by figs on 15/11/20.
//  Copyright © 2015年 luoqj. All rights reserved.
//

#import "selectBankView.h"


@implementation selectBankView
@synthesize bankPicker;
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (id)initWithTitle:(NSString *)title delegate:(id /*<UIActionSheetDelegate>*/)delegate
{
    //    self.delegate = delegate;
    self.bankPicker.dataSource = self;
    self.bankPicker.delegate = self;
    
    //加载数据
    bankNamesArray = [[NSArray alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"BankAndType.plist" ofType:nil]];//银行类型
    banktypesArray = [[bankNamesArray objectAtIndex:1] objectForKey:@"Type"];//银行卡
    
    //初始化默认数据
    self.Bank=[[SelectBank alloc] init];
    self.Bank.bankName=[[banktypesArray objectAtIndex:0]objectForKey:@"name"];
    self.Bank.bankType=[[bankNamesArray objectAtIndex:0]objectForKey:@"Bank"];
    return self;
}
#pragma mark - PickerView lifecycle

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 2;
}

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    switch (component) {
        case 0:
            return [banktypesArray count];
            //            return 11;
            break;
        case 1:
            return [bankNamesArray count];
            //            return 2;
            break;
        default:
            return 0;
            break;
    }
}

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    switch (component) {
        case 0:
            return [[banktypesArray objectAtIndex:row] objectForKey:@"name"];
            //            return @"11";
            break;
        case 1:
            return [[bankNamesArray objectAtIndex:row] objectForKey:@"Bank"];
            //             return @"22";
            break;
        default:
            return nil;
            break;
    }
}

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
}
@end
